package com.amor.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.TextView;

import com.amor.R;
import com.amor.adapter.MenuAdapter;
import com.amor.bean.MenuBean;
import com.amor.utils.MenuDataUtil;

import java.util.ArrayList;

public class MainActivity extends BaseActivity {

    private GridView menu_grid;
    private Context context;
    private ArrayList<MenuBean> menuDatas;
    private MenuAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = this;
        initView();
        initData();
    }

    private void initView() {
        menu_grid = getViewById(R.id.menu_grid);
        ((TextView)getViewById(R.id.menu_top).findViewById(R.id.tv_function)).setText("菜单");
    }

    private void initData() {
        menuDatas = new ArrayList<>();
        menuDatas.addAll(MenuDataUtil.getMenuList());
        adapter = new MenuAdapter(context, menuDatas);
        menu_grid.setAdapter(adapter);
    }
}
